<?php
 
class TransactionCentral_ACH_Transaction_Credit extends TransactionCentral_CurlTransaction
{
    protected $ach_trans;
    
    public function __construct(TransactionCentral_ACH_Transaction $ach_trans)
    {
         $this->ach_trans = $ach_trans;
    }
    
    public function process()
	{
	    $ach_trans = &$this->ach_trans;
	    
	    if(
		    $ach_trans->getAmount()            == '' || 
		    $ach_trans->getTransRoute()        == '' || 
		    $ach_trans->getBankAccountNo()     == '' || 
		    $ach_trans->getName()              == '' ||
		    $ach_trans->getBankAccountType()   == '' ||
		    $ach_trans->getCheckType()         == ''
		  )
		{
			throw new Exception('Name, Amount, Routing Number, Account Number, and RefID must be set.');
		}
		
		return self::curlTransaction(TransactionCentral_Transaction::ACH_TRANS_URL, 
		                             TransactionCentral_Transaction::ACH_CREDIT, 
		                             array(
                                            'MerchantID'		=>  TransactionCentral_Transaction::MERCH_ID,
											'RegKey'		    =>  TransactionCentral_Transaction::REG_KEY,
											'Amount' 		    => 	$ach_trans->getAmount(),
											'TransRoute' 	    =>	$ach_trans->getTransRoute(),
											'BankAccountNo'	    => 	$ach_trans->getBankAccountNo(),
											'RefID' 		    => 	$ach_trans->getRefId(),
											'Name'              => 	$ach_trans->getName(),
											'BankAccountType'   => 	$ach_trans->getBankAccountType(),
											'Address' 		    => 	$ach_trans->getAddress(),
											'ZipCode'           => 	$ach_trans->getZipCode(),
											'ProcessDate'		=> 	$ach_trans->getProcessDate(),
											'checkType'		    => 	$ach_trans->getCheckType(),
											'Description'       => 	$ach_trans->getDescription()
										 ));
    }
}